package com.sa.app.utilities;

import java.util.Date;
import java.util.List;

import android.database.Cursor;

import com.sa.app.objects.DatasheetLine;
import com.sa.app.objects.Item;
import com.sa.app.objects.RealService;
import com.sa.app.objects.Region;
import com.sa.app.objects.VirtualService;

public interface DataBaseManager {
	public void open(String mode);

	public Boolean isOpen();

	// Solo para las sentencias sql que no devuelven datos.
	// Insertar/Actualizar/Borrar
	public void execSQL(String s);

	// Para consultar la base de datos
	public Cursor rawQuery(String s);

	// Para consultar la base de datos y que te lo devuelva en una lista
	public List<List<String>> query(String s);

	// consultar
	public List<List<String>> selectRegion(Integer latitude, Integer longitude);

	public List<List<String>> selectItemByNFCID(String NFCID);

	public List<List<String>> selectItemByAliasID(String aliasID);

	public List<List<String>> selectVirtualService(String nameID, String NFCID);

	public List<List<String>> selectRealService(String nameID, String NFCID);

	public List<List<String>> selectHistory(String NFCID);

	public List<List<String>> selectUse(String NFCID, Date date);

	public Integer getNumUsesFor(String NFCID);

	// insertar o modificar
	public void insertRegion(List<String> region);

	public void insertRegion(String name, Integer latitude, Integer longitude,
			Integer radio);

	public void insertItem(List<String> list);

	public void insertItem(String NFCID, String aliasID, String XMLURL,
			Integer XMLVersion, String manufacturer, String model,
			String imageUrl, Integer latitude, Integer longitude);

	public void insertVirtualService(List<List<String>> virtualServices);

	public void insertVirtualService(String nameID, String NFCID,
			String description, String serviceURL);

	public void insertRealService(List<List<String>> realServices);

	public void insertRealService(String nameID, String NFCID,
			String description, String serviceURL);

	public void insertUse(List<String> use);

	public void insertUse(String NFCID, Integer latitude, Integer longitude,
			Integer type);

	public void insertUse(String NFCID, Integer latitude, Integer longitude,
			Date date, Integer type);

	public void insertUser(Integer userID);

	public void insertSecuritiesVirtualService(
			List<List<String>> securitiesVirtualServices);

	public void insertVirtualSecurity(Integer userID, String nameID,
			String NFCID, Integer securityLevel);

	public void insertParamsVirtualServices(
			List<List<String>> paramsVirtualServices);

	public void insertVirtualParam(String nameID, String NFCID, String value);

	public void insertSecuritiesRealService(
			List<List<String>> securitiesRealServices);

	public void insertRealSecurity(Integer userID, String nameID, String NFCID,
			Integer securityLevel);

	public void insertParamsRealServices(List<List<String>> paramsRealServices);

	public void insertRealParam(String nameID, String NFCID, String value);

	public void insertDatasheet(List<List<String>> datasheet);

	public void insertDatasheet(String NFCID, String key, String value);

	public Boolean oneRegion(Integer latitude, Integer longitude,
			Integer accuracy);

	public Boolean isThereRegionName(String name);

	public Boolean isThereAliasID(String aliasID);

	public void insertAll(List<String> item, List<List<String>> datasheet,
			List<List<String>> virtualServices,
			List<List<String>> realServices,
			List<List<String>> paramsVirtualServices,
			List<List<String>> paramsRealServices,
			List<List<String>> securitiesVirtualServices,
			List<List<String>> securitiesRealServices, List<String> region,
			List<String> use);

	public List<String> getRegionFor(Integer latitude, Integer longitude,
			Integer accuracy);

	public void deleteItem(String nfcId);

	public void closeDB();

	public List<Item> generateItemsList();

	public List<Region> generateRegionsList();

	public List<VirtualService> generateVirtualServicesList(String NFCID);

	public List<RealService> generateRealServicesList(String NFCID);

	public List<DatasheetLine> generateDatasheetList(String NFCID);

	public void deleteAllTables();

	// Metodos que realizan colsultas/modificaciones a la base de datos

	public List<Item> generateItemsListFromRegion(Region r);

	// Estadisticas del Item

	public Date getItemLastUse(String NFCID);

	public Integer getItemNumUses(String NFCID);

	public List<String> getItemLastRegion(String NFCID);

	public Date getItemRegistrationDate(String NFCID);

	// Estadisticas generales
	public String getMostUsed();

	public String getLessUsed();

	public Integer getNumTimesTagged();

	public Integer getNumServicesUsed();

	public Integer getNumItems();

	//

	public boolean isItemInDataBase(String tagID);

}
